package com.icepeach.icepeachhomeback.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.icepeach.icepeachhomeback.entity.Category;
import com.icepeach.icepeachhomeback.entity.Category;
import com.icepeach.icepeachhomeback.req.CategoryListQueryReq;
import com.icepeach.icepeachhomeback.req.CategoryListQueryReq;
import com.icepeach.icepeachhomeback.service.CategoryService;
import com.icepeach.icepeachhomeback.mapper.CategoryMapper;
import org.springframework.stereotype.Service;

/**
* @author 张皓冰
* @description 针对表【category】的数据库操作Service实现
* @createDate 2023-04-25 09:09:50
*/
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category>
    implements CategoryService{

    @Override
    public IPage<Category> getCategorysByPage(CategoryListQueryReq categoryListQueryReq) {

        IPage<Category> page=new Page<>(categoryListQueryReq.getPageNum(),categoryListQueryReq.getPageSize());
        QueryWrapper<Category> queryWrapper=new QueryWrapper<>();
        if(StrUtil.isNotBlank(categoryListQueryReq.getCategoryName())){
            queryWrapper.like("category_name",categoryListQueryReq.getCategoryName());
        }

        return baseMapper.selectPage(page,queryWrapper);
    }
}




